<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class FrontEndController extends MY_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->library('frontend_lib', array('_ci'=>$this));
        $this->load->model('repo/page_model',      'page_model');
        $this->load->model('repo/advertise_model', 'advertise_model');
        $this->load->model('repo/category_model',  'cate_model');
        $this->load->model('repo/raovat_model',    'raovat_model');
    }

    public function renderView($viewName, $data = null) {
        $aPages      = $this->page_model->getPages();
        $aAdvertise  = $this->advertise_model->getAdvertise();
        $aCategories = $this->cate_model->getCategories();
        if(!isset($data['aRaovats_sidebar'])){
            $data['aRaovats_sidebar'] = $this->raovat_model->getStickyWidget(WG_RAO_VAT_LIMIT, 0,
                array(
                    'a.id, a.title, a.slug, a.image, a.description, c.image_folder'
                    )
                );
        }
        $data['template_name'] = $viewName . '.html.php';
        $data['aPages']        = $aPages;
        $data['aCategories']   = $aCategories;
        $data['aAdvertise']    = $aAdvertise;
        $data['info']          = getOption(array('address', 'phone', 'contact_mail', 'fb_fan_page', 'google_plus', 'google_map_key'));
        $layout                = isset($data['no-sidebar']) && $data['no-sidebar']==TRUE ?'layout-no-sidebar':'layout';
        $front_theme           = $this->config->item('front_theme');
        $this->load->view('frontend/' . $front_theme . '/layout/' . $layout . '.html.php', $data);
    }
}

?>